feat: FileStore, Store interface, config file, and content hashing#1
Merged
feat: FileStore, Store interface, config file, and content hashing#1
Conversation
…t hashing - Extract Store interface in types.ts for both in-memory and persistent stores - Add FileStore (file-backed store with atomic writes via temp+rename) - Add .granules.json config file support with CLI flag overrides - Add contentHash (SHA-256) field to Granule type, computed on creation - Add updateGranuleContent method to Store interface - Update Orchestrator and server to accept Store interface - Add comprehensive tests for FileStore and contentHash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
1. Store Interface
Extracted a
Storeinterface intypes.tsthat bothGranuleStore(in-memory) andFileStoreimplement. UpdatedOrchestratorandserver.tsto acceptStoreinstead of concreteGranuleStore.2. FileStore (persistent backend)
New
src/file-store.ts— drop-in replacement that persists to a JSON file on every mutation. Uses atomic writes (temp file + rename) to avoid corruption. Loads existing state on construction. Default path:.granules-state.json.3. Config file support
.granules.jsonin cwd is loaded automatically. Supportsstore,stateFile,port,maxWorkers. CLI flags (--store,--state-file,--port,--max-workers) override config. No config = same behavior as before.4. Spec SHA watermarking
Added
contentHash(SHA-256) field toGranuletype, computed on creation. AddedupdateGranuleContentmethod to update content and recompute hash.5. Tests
Comprehensive tests for FileStore: persistence, reload, atomic writes, contentHash computation. All 90 tests pass.